<template>
  <view v-if="shenheStatus == 0" class="shareOrder">
    <view class="item" v-for="(item, index) in orderList" :key="index">
      <orderItem :order="item" ref="order"></orderItem>
    </view>
    <view class="empty" style="padding-top: 50rpx" v-if="!orderList.length">
      <u-empty mode="data"></u-empty>
    </view>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from '@/components/shenhe/shenhe';
import orderItem from './components/order-item.vue';

export default {
  components: {
    orderItem,

    Shenhe,
  },
  data() {
    return {
      // 订单列表
      orderList: [],
      // 当前加载页面
      page: 1,
      // 是否加载完毕
      noMore: false,
    };
  },
  onLoad(data) {
    uni.setNavigationBarTitle({
      title: this.$t('title.shareOrder'),
    });
    this.getList();
  },
  methods: {
    // 获取订单列表
    async getList() {
      const res = await this.$allrequest.share.getShareOrder(
        {
          page: this.page,
        },
        true
      );
      if (res.code == 0) {
        this.orderList = [...this.orderList, ...res.data.list];
        if (this.orderList.length >= res.data.row_count) {
          this.noMore = true;
        } else {
          this.noMore = false;
        }
      }
    },
  },
  onReachBottom() {
    if (!this.noMore) {
      this.page++;
      this.getList();
    }
  },
};
</script>

<style scoped lang="less">
.shareOrder {
  min-height: 100vh;
  background-color: #f2f2f2;
  font-family: PingFang SC;
  color: #262626;
}
.header-tabs {
  width: 100%;
  padding-top: 20rpx;
  height: 90rpx;
  // line-height: 90rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  z-index: 1000;
  left: 0;
}
.item {
  margin-bottom: 24rpx;
}
</style>
